/**
* 左边菜单
*/ 
<template>
  <el-menu
    default-active="2"
    :collapse="collapsed"
    collapse-transition
    router
    :default-active="$route.path"
    unique-opened
    class="el-menu-vertical-demo"
    background-color="#031A3D"
    text-color="#fff"
  >
    <div class="logobox">
      <img class="logoimg" src="../assets/img/logo.png" alt="" />
    </div>
    <el-submenu
      v-for="menu in allmenu"
      :key="menu.menuid"
      :index="menu.menuname"
    >
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{ menu.menuname }}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item
          v-for="chmenu in menu.menus"
          :index="'/' + chmenu.url"
          :key="chmenu.menuid"
        >
          <span>{{ chmenu.menuname }}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
export default {
  name: "leftnav",
  data() {
    return {
      collapsed: false,
      allmenu: [],
    };
  },
  // 创建完毕状态(里面是操作)
  created() {
    // 获取图形验证码
    let res = {
      success: true,
      data: [
        {
          menuid: 150,
          icon: "icon-gaikuang",
          menuname: "概况",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 159,
              icon: "icon-provider-manage",
              menuname: "概况",
              hasThird: "N",
              url: "charts/statistics",
              menus: null,
            },
            {
              menuid: 160,
              icon: "icon-provider-manage",
              menuname: "数据",
              hasThird: "N",
              url: "charts/statisticsData",
              menus: null,
            },
          ],
        },
        {
          menuid: 1,
          icon: "icon-dianpufill",
          menuname: "店铺管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 2,
              icon: null,
              menuname: "店铺管理",
              hasThird: "N",
              url: "goods/Goods",
              menus: null,
            },
          ],
        },
        {
          menuid: 128,
          icon: "icon-goods-copy",
          menuname: "商品管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 129,
              icon: null,
              menuname: "管理商品",
              hasThird: "N",
              url: "machine/ManageGoods",
              menus: null,
            },
            {
              menuid: 140,
              icon: null,
              menuname: "分类列表",
              hasThird: "N",
              url: "machine/Machine",
              menus: null,
            },
            {
              menuid: 132,
              icon: null,
              menuname: "商品标签",
              hasThird: "N",
              url: "machine/GoodsLabel",
              menus: null,
            },
            {
              menuid: 133,
              icon: null,
              menuname: "商品评论",
              hasThird: "N",
              url: "machine/GoodsReview",
              menus: null,
            },
          ],
        },
        {
          menuid: 33,
          icon: "icon-dingdan",
          menuname: "订单管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 34,
              icon: "icon-order-manage",
              menuname: "订单列表",
              hasThird: "N",
              url: "pay/OrderList",
              menus: null,
            },
          ],
        },
        {
          menuid: 40,
          icon: "icon-kehu",
          menuname: "客户管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 41,
              icon: "",
              menuname: "客户列表",
              hasThird: "N",
              url: "customer/CustomerLists",
              menus: null,
            },
          ],
        },
        {
          menuid: 50,
          icon: "icon-yingxiaozhongxinicon",
          menuname: "营销中心",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 51,
              icon: "",
              menuname: "优惠券",
              hasThird: "N",
              url: "marketing/MarketingList",
              menus: null,
            },
            {
              menuid: 52,
              icon: "",
              menuname: "积分抵扣",
              hasThird: "N",
              url: "marketing/integral",
              menus: null,
            },
            {
              menuid: 53,
              icon: "",
              menuname: "积分商城",
              hasThird: "N",
              url: "marketing/Integralmall",
              menus: null,
            },
            {
              menuid: 54,
              icon: "",
              menuname: "会员设置",
              hasThird: "N",
              url: "marketing/member",
              menus: null,
            },
          ],
        },
      ],
      msg: "success",
    };
    this.allmenu = res.data;
    // 监听
    this.$root.Bus.$on("toggle", (value) => {
      this.collapsed = !value;
    });
  },
};
</script>
<style scoped>
/deep/ .el-submenu > .el-submenu__title {
  padding-left: 0px !important;
}
/* 二级鼠标经过 */
/deep/ .el-submenu > .el-submenu__title {
  color: #fff;
  font-size: 15px;
  height: 50px;
  line-height: 50px;
  padding-left: 20px !important;
} /*二级导航默认*/
#navs {
  padding: 0 !important;
  width: 100%;
}
/deep/.el-menu-vertical-demo {
  background-color: #031a3d;
}

.el-menu-vertical-demo {
  box-sizing: border-box;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
/deep/ .el-submenu__title:hover {
  background-color: #021532;
}
/deep/ .el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  text-align: center;
  margin-top: 1rem;
}
.logobox img {
  height: auto;
  max-height: 50%;
  margin: 1rem 0;
}
</style>
